/*
 * Copyright (C) 2025 ameise <ameise.wang@gmail.com> - All Rights Reserved
 *
 * This file is part of e3log.
 *
 * e3log is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * e3log is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with e3log. If not, see <https://www.gnu.org/licenses/>.
 */

package e3log

import "github.com/fatih/color"

type Level int

const (
	KB = 1024
	MB = 1024 * KB
	GB = 1024 * MB
	TB = 1024 * GB
)

type LogKey = int

const (
	LogKeyTime = iota
	LogKeyLevel
	LogKeyPrefix
	LogKeyCaller
	LogKeyStack
	LogKeyMsg
)

var gKeyNameStr = map[int]string{
	LogKeyTime:   "log_ts",
	LogKeyLevel:  "log_level",
	LogKeyPrefix: "log_prefix",
	LogKeyCaller: "log_caller",
	LogKeyStack:  "log_stack",
	LogKeyMsg:    "log_msg",
}

const (
	LevelTrace Level = iota
	LevelDebug
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
)

var gLevelNameMap = map[string]Level{
	"trace": LevelTrace,
	"debug": LevelDebug,
	"info":  LevelInfo,
	"warn":  LevelWarn,
	"error": LevelError,
	"fatal": LevelFatal,
}

var gLevelStr = map[Level]string{
	LevelTrace: "TRAC",
	LevelDebug: "DEBU",
	LevelInfo:  "INFO",
	LevelWarn:  "WARN",
	LevelError: "ERRO",
	LevelFatal: "FATA",
}

var gLevelColors = map[Level]*color.Color{
	LevelTrace: color.New(color.FgHiCyan),
	LevelDebug: color.New(color.FgHiMagenta),
	LevelInfo:  color.New(color.FgHiGreen),
	LevelWarn:  color.New(color.FgHiYellow),
	LevelError: color.New(color.FgHiRed),
	LevelFatal: color.New(color.FgHiRed, color.Bold),
}

const TimeLayoutMs = "MST 2006-01-02 15:04:05.000"
const TimeLayoutS = "MST 2006-01-02 15:04:05"
const TimeLayoutBackUp = "060102T150405"
const CompressSuffix = ".gz"

var defaultTimeLayout = TimeLayoutMs
